<template>
	<view>
		<view class="h246 topBox pl30 pr36 pt40 pb40 flex col-center">
			<view class="color-f flex row-column  flex1">
				<text class="fs26">余额（¥）</text>
				<view class="fw-700 fs56 mt40" style="font-family: DINAlternate-Bold, DINAlternate;">
					{{(total-0).toLocaleString()}}</view>
			</view>
			<view class="w146 radius33 ">
				<u-button type="primary" shape="circle" style="background-color: #FFB296; height: 58rpx;"
					@click="$jump(`/pages/my/tixian?total=${total}`)">提现</u-button>
			</view>
		</view>
		<view class="pl30 pr30">
			<!-- //选择时间 -->
			<timeSelect @seartime='time' />
			<!-- //列表盒子 -->
			<moneyList :list='list' />
		</view>
	</view>
</template>

<script>
	import timeSelect from '@/components/time_select.vue'
	import moneyList from '@/components/money_list.vue'
	export default {
		components: { timeSelect, moneyList },
		onLoad(opt) {
			this.total = opt.total
		},
		onShow() {
			this.getMoney_data()
			this.getwallet_info()
		},
		data() {
			return {
				total: '',
				query: {
					page: 1,
					size: 20,
					type: 1,
					timestart: '',
					timeend: ''
				},
				list: [],
				//数据总长度
				count: ''
			};
		},
		methods: {
			//选择时间触发
			time(time1, time2) {
				this.query.timestart = time1
				this.query.timeend = time2
				this.query.page = 1
				this.getwallet_info()
			},
			//获取各种余额
			getMoney_data() {
				this.$api.money_data().then(res=>{
					console.log(res)
					// toLocaleString()
					// this.jiantui=res.data.jiantui
					this.total=res.data.total
					// this.zhitui=res.data.zhitui
				})
			},
			//获取列表
			getwallet_info(cd) {
				this.$api.wallet_info(this.query).then(res => {
					this.count = res.data.count
					cd ? this.list = [...this.list, ...res.data.data] : this.list = res.data.data
					console.log(res)
				})
			}
		},
		onReachBottom() {
			if (this.count > this.list.length) {
				this.query.page++
				this.getwallet_info('cd')
			} else {
				this.$msg('暂无更多数据')
			}
		}
	}
</script>

<style lang="scss">
	.topBox {
		background: url(@/static/image/my/zhanghuBG.png) no-repeat;
		background-size: 100% 100%;
	}
</style>
